package Ontology;

import dbcontext.ClassAttrTable;

public class ClassAttr
{
    private int iClassID;			//	Identifier of attribute
    private int iAttrID;			//	Identifier of attribute
    private boolean bIsMarked;		//	Is marked?
    private boolean bIsInherited;	//	Is inherited?
    private int iFatherClassID;		//	Class ID the attribute inherited from
    private int iDomTypeID;  		//	2 Kashevnick
    private double dMin;			//	2 Kashevnick
    private double dMax;			//	2 Kashevnick
    private int iLimited;  			//	2 Kashevnick
    
	//	" DomTypeId: " + rsDB.getInt( "Domtype_id" ) +
	//	" Min: " + rsDB.getInt( "Min" ) + 
	//	" Max: " + rsDB.getInt( "Max" ) +
	//	" Limited: " + rsDB.getInt( "Limited" )

    public ClassAttr ( int iiClassID, int iiAttrID, boolean ibIsInherited, int iiFatherClassID )
    {
    	iClassID = iiClassID;
    	iAttrID = iiAttrID;
    	bIsInherited = ibIsInherited;
    	iFatherClassID = iiFatherClassID;
    }

    public String toString() 
    {
        return "ClassID: " + iClassID + "; AttrID: " + iAttrID + "; Is inherited: " + bIsInherited + "; Father class ID: " + iFatherClassID;
    }
    public String toFileWithTab() 
    {
        return "" + iClassID + "\t" 
        	+ iAttrID + "\t"
        	+ ( bIsInherited ? "T" : "F" );
    }
    /** Stores data to the table 'class_attr' */
    public void toDatabase( java.sql.Connection conn)
    {
        ClassAttrTable.insert(conn, iClassID, iAttrID);
    }
    
    public int getClassID() 
    {
        return iClassID;
    }
    public int getAttrID() 
    {
        return iAttrID;
    }
    public boolean getIsInherited() 
    {
        return bIsInherited;
    }
    public boolean getIsMarked() 
    {
        return bIsMarked;
    }
    public int getFatherClassID() 
    {
        return iFatherClassID;
    }
    
    public void setIsMarked( boolean ibIsMarked ) 
    {
        bIsMarked = ibIsMarked;
        return;
    }
    public void setInherited( int iiClassID, int iiFatherClassID ) 
    {
    	iClassID = iiClassID;
    	iFatherClassID = iiFatherClassID;
    	bIsInherited = true;
        return;
    }
}